//////////////////////////////////////////////////////////////////////////////////////////////////
//	File: Animation.h
//
//	Author: Justin Maza
//
//	Purpose: Handle the animations of all game objects. Uses an anchor point to center all
//			 the images within their frame.
//////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include <Windows.h>
#include <string>
#include <vector>

#include "SGD Wrappers\CSGD_Direct3D.h"
#include "SGD Wrappers\CSGD_TextureManager.h"

using namespace std;
//typedef const WCHAR* TCHAR;

class Animation
{
private:
	struct tFrame
	{
		RECT rFrame;
		POINT ptAnchor;
		float fDuration;
		string Trigger;
		int Triggertype;
	};

	bool	bIsLooping;
	bool	bIsOscillating;
	bool	bIsFlipped;
	int		nImageID;
	bool	bIsPlaying;
	int		nCurrent_Frame;

	vector<tFrame> v_Frames;
	CSGD_TextureManager* pTM;

public:

	// struct to manage the animation's frames
	

	Animation(void);
	~Animation(void);

	void AddFrame(const char* fileName, RECT rFrame, POINT Anchor, float fDuration, bool bOscillating, bool bLooping, DWORD dwColor = D3DCOLOR_XRGB(0,0,0));  // Adds a single frame to the object's vector
	void SetFramesM(const char* fileName, RECT rFrames[], POINT Anchors[], int nArraySize, float fDurations[], bool bOscillating, bool bLooping, int trigTypes[], string Triggers[], DWORD dwColor = D3DCOLOR_XRGB(0, 0, 0));	// Creates an entire animation using an array of RECTS, Anchor Points,
																																														// and the array's size.  Used for custom animations and creating animations
																																														// from irregularly-spaced sprites.

	void SetFramesA(const char* fileName, int nInitialX, int nInitialY, int nWidth, int nHeight, int numCols, int numRows, POINT ptAnchor, bool bOscillating, bool bLooping, DWORD dwColor = D3DCOLOR_XRGB(0, 0, 0)); // Creates an entire animation using the upper-left corner
																																																					 // of the image and the width and height to create the frame.
	//	Accessors																																			    															 // Assumes the animation is using evenly-spaced sprites.
	bool GetIsLooping(void) {return bIsLooping;}
	bool GetIsOscillating(void) {return bIsOscillating;}
	bool GetIsPlaying(void) {return bIsPlaying;}
	int GetImageID(void) {return nImageID;}
	vector<tFrame> GetFrames(void) {return v_Frames;}
	tFrame GetCurrentFrame(void) {return v_Frames[nCurrent_Frame];}
	int GetCurrentFrameIndex(void) {return nCurrent_Frame;}
	void IncrementFrame(void) {nCurrent_Frame++;}

	//	Mutators
	void SetFlippedValue(bool bFlipped) {bIsFlipped = bFlipped;}
	void SetCurrentFrame(int cur) {nCurrent_Frame = cur;}

	//	Animation Commands
	void Play(void) { bIsPlaying = true; nCurrent_Frame = 0;} // Sets playing flag to true and resets the current frame to 0
	void Stop(void)	{bIsPlaying = false;}					  // Sets playing flag to false; Does nothing with the current frame
	void Resume(void) {bIsPlaying = true;}					  // Sets playing flag to true; Does nothing with the current frame
	void Reset(void) {nCurrent_Frame = 0;}					  // Resets current frame to 0


private:
	
};

